function ajax(url) {
    return new Promise((resolve, reject) => {
        let xhr = new XMLHttpRequest();
        xhr.open('get', url);
        xhr.onreadystatechange = () => {
            if(xhr.readyState === 4) {
                if (xhr.status >= 200 && xhr.status <= 299) {
                    let data = xhr.responseText;
                    resolve(JSON.parse(data))
                } else {
                    
                    reject(new Error('请求失败：${xhr.status}'))
                }
            }
        }
        xhr.send();//发送请求
    })
}